package com.tony.activotytest;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

public class ActivityConllector {
    //存放所有活动容器
    public static List<Activity> activities = new ArrayList<>();

    //添加活动
    public static void addActivity(Activity activity){
        if(activity != null){
            activities.add(activity);
        }
    }

    //移除活动
    public static void removeActivity(Activity activity){
        if(activity != null){
            activities.remove(activity);
        }
    }
    //移除并关闭所有的活动
    public static void finishAllActivity(){
        for (Activity activity:activities) {
            if(!activity.isFinishing()){
                activity.finish();
            }
        }
        activities.clear();
    }



}
